import type { DataBase, User } from "./database";

export class UserService {
  constructor(private database: DataBase) {}

  createUser(name: string) {
    const id = Math.floor(Math.random() * 100);
    const newUser: User = { id, name };

    this.database.addUser(newUser);

    return newUser;
  }

  findUser(id: number) {
    return this.database.findUser(id);
  }
}
